﻿using System;
using System.ServiceModel.Web;
using System.Windows;

namespace RESTfulAPI
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        WebServiceHost _serviceHost;
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                StudentQueryService service = new StudentQueryService();
                _serviceHost = new WebServiceHost(service, new Uri("http://localhost:8009/Studentsys"));
                _serviceHost.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            _serviceHost.Close();
        }
    }
}
